home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / Pakiet bezpieczenstwa / mini Pentoo LiveCD 2006.1 / mpentoo-2006.1.iso / livecd.squashfs / usr / lib / mozilla-firefox / include / gfx / nsFont.h < prev    next >
C/C++ Source or Header  |  2006-05-08  |  6KB  |  151 lines

  1. /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
  2. /* ***** BEGIN LICENSE BLOCK *****
  3.  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
  4.  *
  5.  * The contents of this file are subject to the Mozilla Public License Version
  6.  * 1.1 (the "License"); you may not use this file except in compliance with
  7.  * the License. You may obtain a copy of the License at
  8.  * http://www.mozilla.org/MPL/
  9.  *
  10.  * Software distributed under the License is distributed on an "AS IS" basis,
  11.  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  12.  * for the specific language governing rights and limitations under the
  13.  * License.
  14.  *
  15.  * The Original Code is mozilla.org code.
  16.  *
  17.  * The Initial Developer of the Original Code is
  18.  * Netscape Communications Corporation.
  19.  * Portions created by the Initial Developer are Copyright (C) 1998
  20.  * the Initial Developer. All Rights Reserved.
  21.  *
  22.  * Contributor(s):
  23.  *
  24.  * Alternatively, the contents of this file may be used under the terms of
  25.  * either of the GNU General Public License Version 2 or later (the "GPL"),
  26.  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  27.  * in which case the provisions of the GPL or the LGPL are applicable instead
  28.  * of those above. If you wish to allow use of your version of this file only
  29.  * under the terms of either the GPL or the LGPL, and not to allow others to
  30.  * use your version of this file under the terms of the MPL, indicate your
  31.  * decision by deleting the provisions above and replace them with the notice
  32.  * and other provisions required by the GPL or the LGPL. If you do not delete
  33.  * the provisions above, a recipient may use your version of this file under
  34.  * the terms of any one of the MPL, the GPL or the LGPL.
  35.  *
  36.  * ***** END LICENSE BLOCK ***** */
  37.  
  38. #ifndef nsFont_h___
  39. #define nsFont_h___
  40.  
  41. #include "gfxCore.h"
  42. #include "nsCoord.h"
  43. #include "nsString.h"
  44.  
  45. // XXX we need a method to enumerate all of the possible fonts on the
  46. // system across family, weight, style, size, etc. But not here!
  47.  
  48. // Enumerator callback function. Return PR_FALSE to stop
  49. typedef PRBool (*nsFontFamilyEnumFunc)(const nsString& aFamily, PRBool aGeneric, void *aData);
  50.  
  51. // IDs for generic fonts
  52. // NOTE: 0, 1 are reserved for the special IDs of the default variable
  53. // and fixed fonts in the presentation context, see nsPresContext.h
  54. const PRUint8 kGenericFont_NONE         = 0x00;
  55. // Special
  56. const PRUint8 kGenericFont_moz_variable = 0x00; // for the default variable width font
  57. const PRUint8 kGenericFont_moz_fixed    = 0x01; // our special "use the user's fixed font"
  58. // CSS
  59. const PRUint8 kGenericFont_serif        = 0x02;
  60. const PRUint8 kGenericFont_sans_serif   = 0x04;
  61. const PRUint8 kGenericFont_monospace    = 0x08;
  62. const PRUint8 kGenericFont_cursive      = 0x10;
  63. const PRUint8 kGenericFont_fantasy      = 0x20;
  64.  
  65. // Font structure.
  66. struct NS_GFX nsFont {
  67.   // The family name of the font
  68.   nsString name;
  69.  
  70.   // The style of font (normal, italic, oblique)
  71.   unsigned int style : 7;
  72.  
  73.   // Force this font to not be considered a 'generic' font, even if
  74.   // the name is the same as a CSS generic font family.
  75.   unsigned int systemFont : 1;
  76.  
  77.   // The variant of the font (normal, small-caps)
  78.   PRUint8 variant : 7;
  79.  
  80.   // True if the character set quirks (for treatment of "Symbol",
  81.   // "Wingdings", etc.) should be applied.
  82.   PRPackedBool familyNameQuirks : 1;
  83.  
  84.   // The weight of the font (0-999)
  85.   PRUint16 weight;
  86.  
  87.   // The decorations on the font (underline, overline,
  88.   // line-through). The decorations can be binary or'd together.
  89.   PRUint8 decorations;
  90.  
  91.   // The logical size of the font, in nscoord units
  92.   nscoord size;
  93.  
  94.   // The aspect-value (ie., the ratio actualsize:actualxheight) that any
  95.   // actual physical font created from this font structure must have when
  96.   // rendering or measuring a string. A value of 0 means no adjustment
  97.   // needs to be done.
  98.   float sizeAdjust;
  99.  
  100.   // Initialize the font struct with an iso-latin1 name
  101.   nsFont(const char* aName, PRUint8 aStyle, PRUint8 aVariant,
  102.          PRUint16 aWeight, PRUint8 aDecoration, nscoord aSize,
  103.          float aSizeAdjust=0.0f);
  104.  
  105.   // Initialize the font struct with a (potentially) unicode name
  106.   nsFont(const nsString& aName, PRUint8 aStyle, PRUint8 aVariant,
  107.          PRUint16 aWeight, PRUint8 aDecoration, nscoord aSize,
  108.          float aSizeAdjust=0.0f);
  109.  
  110.   // Make a copy of the given font
  111.   nsFont(const nsFont& aFont);
  112.  
  113.   nsFont();
  114.   ~nsFont();
  115.  
  116.   PRBool operator==(const nsFont& aOther) const {
  117.     return Equals(aOther);
  118.   }
  119.  
  120.   PRBool Equals(const nsFont& aOther) const ;
  121.  
  122.   nsFont& operator=(const nsFont& aOther);
  123.  
  124.   // Utility method to interpret name string
  125.   // enumerates all families specified by this font only
  126.   // returns PR_TRUE if completed, PR_FALSE if stopped
  127.   // enclosing quotes will be removed, and whitespace compressed (as needed)
  128.   PRBool EnumerateFamilies(nsFontFamilyEnumFunc aFunc, void* aData) const;
  129.   void GetFirstFamily(nsString& aFamily) const;
  130.  
  131.   // Utility method to return the ID of a generic font
  132.   static void GetGenericID(const nsString& aGeneric, PRUint8* aID);
  133. };
  134.  
  135. #define NS_FONT_STYLE_NORMAL              0
  136. #define NS_FONT_STYLE_ITALIC              1
  137. #define NS_FONT_STYLE_OBLIQUE             2
  138.  
  139. #define NS_FONT_VARIANT_NORMAL            0
  140. #define NS_FONT_VARIANT_SMALL_CAPS        1
  141.  
  142. #define NS_FONT_DECORATION_NONE           0x0
  143. #define NS_FONT_DECORATION_UNDERLINE      0x1
  144. #define NS_FONT_DECORATION_OVERLINE       0x2
  145. #define NS_FONT_DECORATION_LINE_THROUGH   0x4
  146.  
  147. #define NS_FONT_WEIGHT_NORMAL             400
  148. #define NS_FONT_WEIGHT_BOLD               700
  149.  
  150. #endif /* nsFont_h___ */
  151.